package com.zmn.oms.business.impl.messageV1.app;

import com.zmn.common.utils.number.NumberUtil;
import com.zmn.oms.business.interfaces.messageV1.common.MessageSendBaseService;
import com.zmn.oms.business.interfaces.messageV1.app.MessageSendAppService;
import com.zmn.oms.model.dto.messageV1.AppMessageDTO;
import com.zmn.oms.model.dto.messageV1.SendMessageParams;
import com.zmn.oms.model.entity.work.OrderWork;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 类描述：
 *
 * @author yule
 * @date 2020/12/23 14:21
 */
@Service
@Slf4j
public class MessageSendAppServiceImpl implements MessageSendAppService {

    @Autowired
    private MessageSendBaseService messageSendBaseService;

    @Override
    public boolean pushAppMessageInfo(SendMessageParams sendMessageParams) {
        // TODO 预留方法，可以用于切面app消息发送

        return false;
    }

    @Override
    public boolean pushAppMessageInfo(Integer ruleId, String params, OrderWork orderWork) {
        if (NumberUtil.isNullOrZero(orderWork.getMasterId())) {
            return false;
        }
        AppMessageDTO appMessageDTO = AppMessageDTO.builder()
                .orderId(orderWork.getOrderId())
                .plat(orderWork.getPlatWork())
                .masterId(orderWork.getMasterId())
                .ruleId(ruleId)
                .params(params)
                .build();
        return messageSendBaseService.sendAndroidAndIOSMessage(appMessageDTO);
    }
}
